package com.ptl.bp.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Comment;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 便携式电池实体类
 */
@Schema(description = "便携式电池")
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "portable_battery")
@Entity(name = "portable_battery")
@org.hibernate.annotations.Table(appliesTo = "portable_battery", comment = "用户信息")
public class PortableBatteryEntity extends BaseEntity {

    // ==================== 基本信息 ====================
    @NotNull(message = "制造地点不能为空")
    @Schema(description = "制造地点", required = true, example = "深圳市宝安区石岩街道上屋社区爱群路同富裕工业区4-7#厂房一层-五层")
    @Comment(value = "制造地点")
    @Column(name = "manufacturing_location", length = 500, nullable = false)
    @TableField("manufacturing_location")
    private String manufacturingLocation;

    @NotNull(message = "制造日期不能为空")
    @DateTimeFormat(pattern = "yyyy-MM")
    @Schema(description = "制造日期", required = true, example = "2025-09")
    @Column(name = "manufacturing_date", nullable = false)
    @TableField("manufacturing_date")
    private LocalDateTime manufacturingDate;

    @NotNull(message = "电池类别不能为空")
    @Schema(description = "电池类别", required = true, example = "便携式电池")
    @Column(name = "battery_category", length = 100, nullable = false)
    @TableField("battery_category")
    private String batteryCategory;

    @NotNull(message = "电池质量不能为空")
    @Schema(description = "电池质量", required = true, example = "0.5")
    @Column(name = "battery_mass", precision = 10, scale = 3, nullable = false)
    @TableField("battery_mass")
    private BigDecimal batteryMass;

    @NotNull(message = "额定容量不能为空")
    @Schema(description = "额定容量", required = true, example = "8")
    @Column(name = "rated_capacity", precision = 10, scale = 3, nullable = false)
    @TableField("rated_capacity")
    private BigDecimal ratedCapacity;

    // ==================== 标识符和产品数据 ====================
    @NotNull(message = "电池护照标识符不能为空")
    @Schema(description = "电池护照标识符", required = true, example = "PTL-BXS-202509002")
    @Column(name = "battery_passport_id", length = 100, nullable = false, unique = true)
    @TableField("battery_passport_id")
    private String batteryPassportId;

    @NotNull(message = "电池标识符不能为空")
    @Schema(description = "电池标识符", required = true, example = "LN-X1-C8-BLA")
    @Column(name = "battery_id", length = 100, nullable = false, unique = true)
    @TableField("battery_id")
    private String batteryId;

    @NotNull(message = "制造商标识符和信息不能为空")
    @Schema(description = "制造商标识符和信息", required = true, example = "LNBD-C-B8-2025Q3-00123456")
    @Column(name = "manufacturer_id", length = 100, nullable = false)
    @TableField("manufacturer_id")
    private String manufacturerId;

    // ==================== 符号、标签、符合性声明文档 ====================
    @Schema(description = "分类回收符号图形")
    @Column(name = "recycling_symbol_graphic", length = 200)
    @TableField("recycling_symbol_graphic")
    private String recyclingSymbolGraphic;

    @Schema(description = "镉和铅符号图形")
    @Column(name = "cadmium_lead_symbol_graphic", length = 200)
    @TableField("cadmium_lead_symbol_graphic")
    private String cadmiumLeadSymbolGraphic;

    @Schema(description = "灭火剂类型", example = "A，K")
    @Column(name = "fire_extinguishing_agent", length = 50)
    @TableField("fire_extinguishing_agent")
    private String fireExtinguishingAgent;

    @Schema(description = "不可充电符号图形")
    @Column(name = "non_rechargeable_graphic", length = 200)
    @TableField("non_rechargeable_graphic")
    private String nonRechargeableGraphic;

    @Schema(description = "标签和符号的含义", example = "铅 (Pb)含量超过0.004%")
    @Column(name = "label_symbol_meaning", length = 500)
    @TableField("label_symbol_meaning")
    private String labelSymbolMeaning;

    @Schema(description = "欧盟符合性声明文档")
    @Column(name = "eu_declaration_of_conformity", length = 500)
    @TableField("eu_declaration_of_conformity")
    private String euDeclarationOfConformity;

    @Schema(description = "尽职调查报告文档")
    @Column(name = "due_diligence_report", length = 500)
    @TableField("due_diligence_report")
    private String dueDiligenceReport;

    // ==================== 电池材料和组成 ====================
    @NotNull(message = "电池化学体系不能为空")
    @Schema(description = "电池化学体系", example = "NCM")
    @Column(name = "battery_chemistry", length = 50, nullable = false)
    @TableField("battery_chemistry")
    private String batteryChemistry;

    @Schema(description = "关键原材料")
    @Column(name = "critical_raw_material", length = 200)
    @TableField("critical_raw_material")
    private String criticalRawMaterial;

    @Schema(description = "有害物质")
    @Column(name = "hazardous_substance", length = 200)
    @TableField("hazardous_substance")
    private String hazardousSubstance;

    @Schema(description = "物质对环境、人类健康、安全、人员的影响")
    @Column(name = "substance_impact_description", columnDefinition = "TEXT")
    @TableField("substance_impact_description")
    private String substanceImpactDescription;

    // ==================== 废旧电池预防与管理信息 ====================
    @Schema(description = "关于最终用户在促进废物预防方面的作用的信息文档链接")
    @Column(name = "waste_prevention_info", length = 500)
    @TableField("waste_prevention_info")
    private String wastePreventionInfo;

    @Schema(description = "关于最终用户在促进废电池分类收集方面的作用的信息文档链接")
    @Column(name = "waste_sorting_collection_info", length = 500)
    @TableField("waste_sorting_collection_info")
    private String wasteSortingCollectionInfo;

    @Schema(description = "关于电池收集、为第二次生命做准备以及生命终结时的处理的信息文档链接")
    @Column(name = "battery_end_of_life_info", length = 500)
    @TableField("battery_end_of_life_info")
    private String batteryEndOfLifeInfo;

    @Schema(description = "安全措施文档链接（仅限合法权益方和欧盟委员会访问）")
    @Column(name = "safety_measures_info", length = 500)
    @TableField("safety_measures_info")
    private String safetyMeasuresInfo;

    @Enumerated(EnumType.STRING)
    @Comment("电池护照状态")
    @Schema(description = "电池护照状态", example = "DRAFT")
    private BatteryPassport.PassportDocumentStatus documentStatus = BatteryPassport.PassportDocumentStatus.DRAFT;

}